package com.tuanzi.loan.business.service.xhh.settlementsystem.impl;

import com.tuanzi.loan.business.entity.xhh.settlementsystem.XhhSettlementIncomeActivity;
import com.tuanzi.loan.business.repository.xhh.settlementsystem.XhhSettlementIncomeActivityRepository;
import com.tuanzi.loan.business.service.xhh.settlementsystem.XhhSettlementIncomeActivityService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.core.service.CommonServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.retry.RetryException;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * @author caiwanlin
 * @create 2018-08-20 20:28
 */
@Debug
@Service
@Transactional
@Retryable(value = {RetryException.class})
public class XhhSettlementIncomeActivityServiceImpl extends CommonServiceImpl<XhhSettlementIncomeActivity,Long> implements XhhSettlementIncomeActivityService {

    @Autowired
    private XhhSettlementIncomeActivityRepository xhhSettlementIncomeActivityRepository;

    @Override
    protected JpaRepository<XhhSettlementIncomeActivity, Long> getRepository() {
        return xhhSettlementIncomeActivityRepository;
    }

    @Override
    public List<XhhSettlementIncomeActivity> findAllByIncomeId(Long incomeId) {
        return xhhSettlementIncomeActivityRepository.findAllByIncomeId(incomeId);
    }

    @Override
    public Integer getUv(Date startTime, Date endTime, List<Long> activityIdList) {
        return xhhSettlementIncomeActivityRepository.getUv(startTime,endTime,activityIdList);
    }

    @Override
    public void deleteByCompanyId(Long id) {
        xhhSettlementIncomeActivityRepository.deleteByCompanyId(id);
    }

    @Override
    public void deleteByProductId(Long id) {
        xhhSettlementIncomeActivityRepository.deleteByProductId(id);
    }
}
